import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },
  server: {
    open: true,
    http: true,
    ssr: false,
    // 设置代理
    proxy: {
      '/api-main': {
        target: 'http://127.0.0.1:5134/api-main',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api-main/, ""),
      },
      '/api-device': {
        target: 'http://127.0.0.1:5207/api-device',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api-device/, ""),
      }
    }
  }
})
